-- @owner:宋菲
-- @date:2024-03-15
-- @testpoint:1.测试创建函数，函数名称大小写不敏感，合理报错

--开启参数
set enable_ignore_case_in_dquotes to on;

--创建表;expect:成功
create table t_ignore_case_in_dquotes_create_case0019(col1 int,col2 int); 

--step1:创建函数名为全小写;expect:成功
create or replace function "f_ignore_case_in_dquotes_create_case0019_1"("col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_create_case0019 values(1,1);
    return col;
end;
$$language plpgsql;
/

--step2:创建函数名为全大写;expect:成功
create or replace function "F_IGNORE_CASE_IN_DQUOTES_CREATE_CASE0019_2"("COL" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_create_case0019 values(2,2);
    return col;
end;
$$language plpgsql; 
/

--step3:创建函数名为大小写混合;expect:成功
create or replace function "f_IgNOrE_CasE_IN_dquotes_create_cASe0019_3"("Col" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_create_case0019 values(3,3);
    return col;
end;
$$language plpgsql;
/

--step4:创建函数名带有特殊符号;expect:成功
create or replace function "f_IGNORE_CASE_IN_dquotes_create_CASE0019_!@#$%^&*()?<>:;=+-_4"("Col_!@#$%^&*()?<>:;=+-" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_create_case0019 values(4,4);
    return "col_!@#$%^&*()?<>:;=+-";
end;
$$language plpgsql;
/

--step5:创建函数名带有单引号;expect:成功
create or replace function "f_IGNORE_CASE_IN_dquotes_create_CASE0019_'''_5"("Col_'''" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_create_case0019 values(5,5);
    return "col_'''";
end;
$$language plpgsql;
/

--step6:创建函数名带有双引号;expect:成功
create or replace function "f_IGNORE_CASE_IN_dquotes_create_CASE0019_""""""_6"("Col_""""""" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_create_case0019 values(6,6);
    return "col_""""""";
end;
$$language plpgsql;
/

--step7:创建函数名带有单引号、双引号混合;expect:成功
create or replace function "F_IGNORE_CASE_IN_dquotes_create_case0019_''""_7"("Col_''""" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_create_case0019 values(7,7);
    return "col_''""";
end;
$$language plpgsql;
/

--step8:异常情况，创建已经存在的小写对象名的对象;expect:报错ERROR: already exists
create or replace function f_ignore_case_in_dquotes_create_case0019_8(col int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_create_case0019 values(8,8);
    return col;
end;
$$language plpgsql;
/

create function "F_IGNORE_CASE_IN_DQUOTES_CREATE_CASE0019_8"("COL" int) returns int
as $$
begin
    insert into t_ignore_case_in_dquotes_create_case0019 values(8,8);
    return col;
end;
$$language plpgsql;
/

--step9:清理环境:expect:成功(9 row)
drop function f_ignore_case_in_dquotes_create_case0019_1;

drop function f_ignore_case_in_dquotes_create_case0019_2;

drop function f_ignore_case_in_dquotes_create_case0019_3;

drop function "f_ignore_case_in_dquotes_create_case0019_!@#$%^&*()?<>:;=+-_4";

drop function "f_ignore_case_in_dquotes_create_case0019_'''_5";

drop function "f_ignore_case_in_dquotes_create_case0019_""""""_6";

drop function "f_ignore_case_in_dquotes_create_case0019_''""_7";

drop function f_ignore_case_in_dquotes_create_case0019_8;

drop table t_ignore_case_in_dquotes_create_case0019;

--关闭参数
set enable_ignore_case_in_dquotes to off;
